//
//  XJSureOrderSectionHeaderView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/6/12.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJSureOrderSectionHeaderView.h"
@interface XJSureOrderSectionHeaderView()
@property(nonatomic, strong) UIView *bgView; // 背景
@property(nonatomic, strong) UIImageView *iconIv;//商铺图标
@property(nonatomic, strong) UILabel *shopNameLb; //商铺名字
@property(nonatomic, strong) UIImageView *arrwoIv; // 箭头

@end
@implementation XJSureOrderSectionHeaderView

//继承自他就要使用它的初始化方法  UITableViewHeaderFooterView 
#pragma mark - 1 init

// ❌等着炸吧
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

// ✅
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    if(self){
        [self setupView];
    }
    return self;
}

- (void)setupView {
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.iconIv];
    [self.bgView addSubview:self.shopNameLb];
    [self.bgView addSubview:self.arrwoIv];
}



#pragma mark - 2 lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UIImageView *)iconIv {
    if (!_iconIv) {
        _iconIv = [UIImageView new];
        _iconIv.image = [UIImage imageNamed:@"address_list_on"];
    }
    return _iconIv;
}
- (UILabel *)shopNameLb {
    if (!_shopNameLb) {
        _shopNameLb = [UILabel new];
    }
    return _shopNameLb;
}

- (UIImageView *)arrwoIv {
    if (!_arrwoIv) {
        _arrwoIv = [UIImageView new];
        _arrwoIv.image =  [UIImage imageNamed:@"direction_right_black"];
    }
    return _arrwoIv;
}


#pragma mark - 3 layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat k15 = 15.0;
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    [self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(k15);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(12, 15));
    }];
    
    [self.shopNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIv.mas_right).offset(10);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(150, 30));
    }];
    [self.arrwoIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_right).offset(-k15);
        make.size.mas_equalTo(CGSizeMake(12, 12));
        make.centerY.equalTo(self.bgView.mas_centerY);
    }];
    
}


#pragma mark - 4 configure
- (void)configureXJSureOrderSectionHeaderViewWithShopName:(NSString *)shopName {
    self.shopNameLb.text = shopName;
}


@end

























